package com.stylefeng.guns.common.util;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 处理各种简单运算
 * Created by lyz on 2018/2/3.
 */
public class MathUtil {

    /**
     *  向上取整，返回2位
     * @param value
     * @return
     */
    public static BigDecimal getUp2(Double value){
        return new BigDecimal(value).setScale(2, RoundingMode.UP);
    }

    /**
     * 保留两位，后面的删除
     * @param value
     * @return
     */
    public static BigDecimal getUp2(BigDecimal value){
        return value.setScale(2, BigDecimal.ROUND_DOWN);
    }

    public static BigDecimal getUpX(BigDecimal value ,int scale){
        return value.setScale(scale,RoundingMode.UP);
    }


}
